package cn.com.device.monitor.mqtt;

import cn.com.device.monitor.vo.MqttMessgeVO;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class MqttTest implements CommandLineRunner {

    @Autowired
    private MqttMessageSender mqttMessageSender;

    @Override
    public void run(String... args) throws Exception {
        MqttMessgeVO data = new MqttMessgeVO();
        data.setDeviceId("c1001");
        data.setStatus("run");
        data.setTemperature("45.3");
        data.setWarn("1");
        // 发送一条测试消息
        ObjectMapper mapper = new ObjectMapper();
        //mqttMessageSender.sendMessage(mapper.writeValueAsString(data));
    }
}
